export function success(title, duration = 2000) {
	uni.showToast({
		title: String(title),
		icon: 'success',
		duration
	})
}

export function msgTo(title, callback, duration = 1500) {
	uni.showToast({
		title: String(title),
		icon: 'success',
		duration
	})
	setTimeout(() => {
		callback && callback()
	}, duration);
}

export function validToken() {
	return new Promise((reslove, reject) => {
		if (!uni.getStorageSync('openId')) {
			uni.showToast({
				title: '请登录',
				icon: 'none',
				duration: 1000
			})
			setTimeout(() => {
				uni.navigateTo('/pages/my/index')
			}, 300);
			return reject('请登录')
		}
		return reslove()
	})
}

export function getFwsc(str) {
	if (!str) return '0分钟'
	let arr = str.split('.')
	let minute = Math.ceil(arr[1] * 0.6)
	if (arr[0] == 0) return `${minute}分钟`
	return `${arr[0]}小时${minute}分钟`
}

export function getAuditStatus(status) {
	let state = {
		'1': '审批中',
		'2': '已通过',
		'-1': '未通过'
	}
	return state[status]
}